Skip to content

Update UserInfo.kt#6

Closed
Alqueraf wants to merge 2 commits intoonelogin:developfrom
Alqueraf:patch-1
Closed

Update UserInfo.kt#6
Alqueraf wants to merge 2 commits intoonelogin:developfrom
Alqueraf:patch-1

Conversation

@Alqueraf
Copy link
Copy Markdown

Update the UserInfo class to match the JSON keys returned from the /me endpoint and parsed with Gson.

  • Add snake_case SerializedName for multiple word parameters.
  • Set updatedAt type to Int.

- Add snake_case SerializedName for multiple word parameters.
- Set updatedAt type to Int.
@Subterrane Subterrane requested a review from Copilot January 7, 2026 21:29
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the UserInfo data class to properly map JSON responses from the /me endpoint using Gson annotations. The changes ensure field names match the snake_case convention used in the API response and correct the data type for the updatedAt field.

  • Adds @SerializedName annotations to all fields to explicitly map snake_case JSON keys to camelCase Kotlin properties
  • Changes updatedAt type from String? to Int? to match the actual API response format

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +6 to +8
@SerializedName("sub")
val sub: String,
@SerializedName("email")
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The @SerializedName annotations for 'sub' and 'email' are unnecessary since the JSON keys already match the Kotlin property names. Remove these redundant annotations to reduce clutter and follow the convention of only annotating fields where the names differ.

Suggested change
@SerializedName("sub")
val sub: String,
@SerializedName("email")
val sub: String,

Copilot uses AI. Check for mistakes.
val email: String,
@SerializedName("preferred_username")
val preferredUsername: String?,
@SerializedName("name")
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The @SerializedName annotation for 'name' is unnecessary since the JSON key matches the Kotlin property name. Consider removing this redundant annotation.

Suggested change
@SerializedName("name")

Copilot uses AI. Check for mistakes.
val givenName: String?,
@SerializedName("family_name")
val familyName: String?,
@SerializedName("groups")
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The @SerializedName annotation for 'groups' is unnecessary since the JSON key matches the Kotlin property name. Consider removing this redundant annotation.

Suggested change
@SerializedName("groups")

Copilot uses AI. Check for mistakes.
Subterrane added a commit that referenced this pull request Mar 17, 2026
UserInfo fields with snake_case JSON keys (preferred_username, given_name,
family_name, updated_at) were silently deserializing as null because Gson
performs exact name matching against the camelCase Kotlin property names.

Also changes updatedAt from String? to Long? to match the OIDC spec
(updated_at is a Unix epoch timestamp), adds ProGuard consumer rules to
prevent R8 from stripping Gson model fields, and adds deserialization tests.

Supersedes #6, #13, #16. [no-ado]
@Subterrane
Copy link
Copy Markdown
Collaborator

Thanks for the contribution — this correctly identified that @SerializedName annotations are needed for snake_case fields.

One issue: updatedAt is typed as Int?, but the OIDC spec defines updated_at as a Unix epoch timestamp. Int maxes out at 2,147,483,647 (January 2038), so this would overflow. It should be Long?.

I've opened PR #23 which combines the fixes from this PR, PR #13, and PR #16, with the correct Long? type, ProGuard consumer rules, and deserialization tests.

@Subterrane Subterrane mentioned this pull request Mar 17, 2026
@Subterrane
Copy link
Copy Markdown
Collaborator

#23

@Subterrane Subterrane closed this Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants